#include<iostream>
using namespace std;
#define ERROR NULL
typedef int ElementType;
typedef struct LNode*PtrToLNode;
struct LNode
{
	ElementType Coef;
	ElementType Expon;
	PtrToLNode Next;
};
typedef PtrToLNode List;

List create()
{
	List L;
	L=(List)malloc(sizeof(struct LNode));
	L->Next=NULL;
	return L;
}

List Insert()
{
	List list1,list2;
	list1=list2=create();
	int a,b;
	char c;
	do
    {
        scanf("%d",&a);
		scanf("%d",&b);
		list1->Next=(List)malloc(sizeof(struct LNode));
		list1->Next->Coef=a;
		list1->Next->Expon=b;
		list1=list1->Next;
		list1->Next=NULL;
    }while((c=getchar())!= '\n');
	return list2;
}

List qiudao(List L1)
{
	List list1,list2;
	list1=list2=create();
	while(L1->Next!=NULL)
	{
		if(L1->Next->Expon==0)
			break;
		else
		{
		    list1->Next=(List)malloc(sizeof(struct LNode));
		    list1->Next->Coef=L1->Next->Coef*L1->Next->Expon;
		    list1->Next->Expon=L1->Next->Expon-1;
		    list1=list1->Next;
		    list1->Next=NULL;
		    L1=L1->Next;
		}
	}
	return list2;
}

int main()
{
	List list1,list2;
	int a=0;
	list1=Insert();
	list2=qiudao(list1);
	if(list2->Next!=NULL)
	{
		while(list2->Next)
		{
			if(a==0)
			{
				list2=list2->Next;
				printf("%d %d",list2->Coef,list2->Expon);
				a++;
			}
			else
			{
				list2=list2->Next;
				printf(" %d %d",list2->Coef,list2->Expon);
			}
		}
	}
	else
	{
		printf("0 0");
	}
	return 0;
}
